<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of ExportPdf
 * $this->outputData['tcpdf']= $this->config->item('tcpdf');
 * @author loind
 */
class Export extends CI_Controller {
    //put your code here 
    //Global variable  
   public $outputData ='';
    public function __construct() {
        parent::__construct();
        $this->load->model('Item_model','itemEntry');
        
    } 
    
    function exportpdf() {
        
        $session_id = $this->session->userdata('session_id');
       // $category_Id = $this->uri->segment(3);
        
       if($this->session->userdata('logged_in')) {
        //User is logged in
            $this->outputData['category_1'] = $this->itemEntry->get_top_five_entries_by_categoryId_UserId(1);
            $this->outputData['category_2'] = $this->itemEntry->get_top_five_entries_by_categoryId_UserId(2);
            $this->outputData['category_3'] = $this->itemEntry->get_top_five_entries_by_categoryId_UserId(3);
        } else {
        //User is not logged in
            $this->outputData['category_1'] = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(1,$session_id);
            $this->outputData['category_2'] = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(2,$session_id);
            $this->outputData['category_3'] = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(3,$session_id);
        } 
       
        //$url = "http://wii-local.com/index.php/export/exportContent";
	  $url = "http://localhost:8080/wii/index.php/export/exportContent";
        $this->load->library('Mpdf'); 
        $html = file_get_contents($url);
        //var_dump($html); exit(0);
        $mpdf=new Pdf('');
        $mpdf->useSubstitutions = true; // optional - just as an example
        //$mpdf->SetHeader($url.'||Page {PAGENO}');  // optional - just as an example
	  $mpdf->SetHeader('What is important in Advertisment industry?'.'||Page {PAGENO}');  // optional - just as an example
        $mpdf->CSSselectMedia='mpdf'; // assuming you used this in the document header
        $mpdf->setBasePath($url);
        $mpdf->WriteHTML($html);
        $mpdf->Output();
         
	//print_r($this->outputData['homeRows']);
        
        //$this->load->view('previewpdf', $this->outputData);
       // $this->load->view('exportpdf/export', $this->outputData);
        
    }
    
    function exportpdf2() { 
        $url = "http://wii-local.com/index.php/export/exportContent";
        $this->load->library('Mpdf'); 
        $html = file_get_contents($url);
        //var_dump($html); exit(0);
        $mpdf=new Pdf('');
        $mpdf->useSubstitutions = true; // optional - just as an example
        //$mpdf->SetHeader($url.'||Page {PAGENO}');  // optional - just as an example
	  $mpdf->SetHeader('What is important in Advertisment industry?'.'||Page {PAGENO}');  // optional - just as an example
        $mpdf->CSSselectMedia='mpdf'; // assuming you used this in the document header
        $mpdf->setBasePath($url);
        $mpdf->WriteHTML($html);
        $mpdf->Output();
         
	//print_r($this->outputData['homeRows']);
        
        //$this->load->view('previewpdf', $this->outputData);
       // $this->load->view('exportpdf/export', $this->outputData);
        
    }
    function exportContent(){
       $session_id = $this->session->userdata('session_id');
       // $category_Id = $this->uri->segment(3);
        
       if($this->session->userdata('logged_in')) {
        //User is logged in
            $this->outputData['category_1'] = $this->itemEntry->get_top_five_entries_by_categoryId_UserId(1);
            $this->outputData['category_2'] = $this->itemEntry->get_top_five_entries_by_categoryId_UserId(2);
           // $this->outputData['category_3'] = array("1","2","3");
            
            
            
        } else {
        //User is not logged in
            $this->outputData['category_1'] = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(1,$session_id);
            $this->outputData['category_2'] = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(2,$session_id);
		$this->outputData['category_3'] = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(3,$session_id);
		$this->outputData['category_4'] = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(4,$session_id);
		$this->outputData['category_5'] = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(5,$session_id);
		$this->outputData['category_6'] = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(6,$session_id);
		$this->outputData['category_7'] = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(7,$session_id);

            /*
		$cate_3_ex=array("default.png|sdf|sdf sdf","default.png|3 wsdf|s","default.png|sdf|sdfsd");
            $cate_3 = $this->itemEntry->get_top_five_entries_by_categoryId_SessionId(3,$session_id);
            $cate_3_ex=array();
            foreach ($cate_3 as $c1)
            {
                $str=$c1->avatar."|".$c1->name."|".$c1->company;
                 
                $cate_3_ex[]=$str;
            }
         //   var_dump($cate_3_ex);  
            $this->outputData['category_3'] =$cate_3_ex;
*/
        } 
        $this->load->view('exportpdf/cate_preview', $this->outputData); 
    }
}

?>
